﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FoundationLib.Common.Extensions
{
	/// <summary>
	/// Defines extension methods for the <see cref="Int32"/> type.
	/// </summary>
	public static class Int32Extensions
	{
		/// <summary>
		/// Takes the given <see cref="Int32"/> instance as a UNIX timestamp and converts it to a valid 
		/// <see cref="DateTime"/> instance.
		/// </summary>
		/// <param name="value">The UNIX timestamp</param>
		/// <returns>A <see cref="DateTime"/> instance</returns>
		public static DateTime ToDateTime(this Int32 value)
		{
			DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
			return (origin.AddSeconds(value));
		}
	}
}
